package com.my.mall.client.shoppingCart.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.my.mall.client.shoppingCart.dao.ShoppingCartClientDao;
import com.my.mall.client.shoppingCart.vo.ShoppingCartClientVo;

@Service
public class ShoppingCartClientService {

	@Autowired
	ShoppingCartClientDao shoppingCartClientDao;

	public List<ShoppingCartClientVo> selectShoppingCartList(int userId) {
		return shoppingCartClientDao.selectShoppingCartList(userId);
	}

	public int updatePlus(int id, int number) {
		return shoppingCartClientDao.updatePlus(id, number);
	}

	public int updateMinus(int id, int number) {
		return shoppingCartClientDao.updateMinus(id, number);
	}

	public int save(int userId, int goodsId, int buyCount) {
		return shoppingCartClientDao.save(userId, goodsId, buyCount);
	}
	
	public int deleteGoods(int id) {
		return shoppingCartClientDao.deleteGoods(id);
	}
	
	public void emptyShoppingCart(int userId) {
		shoppingCartClientDao.emptyShoppingCart(userId);
	}
	
	public Double getShoppingCartTotalPrice(List<ShoppingCartClientVo> list) {
		Double shoppingCartTotalPrice = 0.0;
		for (ShoppingCartClientVo sccv : list) {
			shoppingCartTotalPrice += sccv.getTotalPrice();
		}
		return shoppingCartTotalPrice;
	}
}
